package edu.scau.mis.pos.service.impl;

import edu.scau.mis.pos.domain.Vip;
import edu.scau.mis.pos.mapper.VipMapper;
import edu.scau.mis.pos.service.IVipService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * (Vip)表服务实现类
 *
 * @author CJW
 * @since 2024-04-18 17:39:38
 */
@Service("vipService")
public class VipServiceImpl implements IVipService {
    @Resource
    private VipMapper vipMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param vipId 主键
     * @return 实例对象
     */
    @Override
    public Vip selectById(Long vipId) {
        return this.vipMapper.selectById(vipId);
    }

    /**
     * 查询指定行
     *
     * @param vip 筛选条件
     * @return 查询结果
     */
    @Override
    public List<Vip> selectList(Vip vip) {
        return this.vipMapper.selectList(vip);
    }

    /**
     * 新增数据
     *
     * @param vip 实例对象
     * @return 实例对象
     */
    @Override
    public Vip insert(Vip vip) {
        vip.setCreateTime(new Date());
        this.vipMapper.insert(vip);
        return vip;
    }

    /**
     * 修改数据
     *
     * @param vip 实例对象
     * @return 实例对象
     */
    @Override
    public Vip update(Vip vip) {
        vip.setUpdateTime(new Date());
        this.vipMapper.update(vip);
        return this.selectById(vip.getVipId());
    }

    /**
     * 通过主键批量删除数据
     *
     * @param vipId 主键
     * @return 影响记录数
     */
    @Override
    public int deleteByIds(Long[] vipId) {
        return this.vipMapper.deleteByIds(vipId);
    }
}
